﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace ajayumi.Platform.Search.Win
{
    public partial class SearchRangeDropdownList : ajayumi.Platform.Search.Win.SearchControlBase
    {

        public override string DisplayText
        {
            set
            {
                this.label1.Text = value;
            }
        }

        public SearchRangeDropdownList()
        {
            InitializeComponent();
        }

        public SearchRangeDropdownList(SearchOption[] options, SearchOption[] options2)
            : this()
        {
            this.SetDataSource(this.comboBox1, options);
            if (options2 == null || options2.Length <= 0)
            {
                this.SetDataSource(this.comboBox2, options);
                return;
            }
            this.SetDataSource(this.comboBox2, options2);
        }

        private void SetDataSource(ComboBox cbo, SearchOption[] options)
        {
            cbo.DisplayMember = "DisplayText";
            cbo.ValueMember = "Value";
            cbo.DataSource = options;
        }

        internal override SearchItemValue GetSearchItemValue()
        {
            return new SearchItemValue()
            {
                ItemIndex = this.ItemIndex,
                Value1 = this.comboBox1.SelectedValue.ToString(),
                Value2 = this.comboBox2.SelectedValue.ToString()
            };
        }
    }
}
